#include <bits/stdc++.h>
using namespace std;

struct car{
    int begin; int end; int count;

    bool operator< (const car &b) const{
        if (this->begin != b.begin) return this->begin < b.begin;
        else return this->end < b.end;
    }

    void output(){cout << "begin, end, count = " << this->begin << " " << this->end << " " << this->count << endl;}

    car(int b, int e, int c){
        this->begin = b; this->end = e; this->count = c;
    }
};

int T, n, m, L, V, V2, p1[100010];
vector<car> vec;

void get_car(){
    int d, v, a;
    cin >> d >> v >> a;
    if (v <= V){
        if (a <= 0) return;
        int tmp = (V2-v*v);
        if (tmp % (2*a)) vec.push_back({d+tmp/(2*a), L, 0});
        else vec.push_back({d+tmp/(2*a)-1, L, 0});
    }
    else {
        if (a >= 0) vec.push_back({d, L, 0});
        else {
            int tmp = (v*v-V2); a = -a;
            if (tmp % (2*a)) vec.push_back({d, d+tmp/(2*a), 0});
            else vec.push_back({d, d+tmp/(2*a)-1, 0});
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    //freopen("detectd/detect2.in", "r", stdin);
    //freopen("detectd/detect2.out", "w", stdout);
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    cin >> T;
    for (int kkk=0; kkk<T; ++kkk){
        vec.clear(); vec.reserve(n);
        int ans1 = 0; int ans2 = 0;
        cin >> n >> m >> L >> V;
        V2 = V * V;
        for (int i=0; i<n; ++i) get_car();
        sort(vec.begin(), vec.end());
        for (int i=0; i<m; ++i) cin >> p1[i];
        for (int i=m-1; i>=0; --i){
            int p = p1[i];
            bool flag = false;
            //for (car &c1 : vec) c1.output(); cout << "SPLIT\n";
            for (car &c : vec){
                if (c.begin <= p){
                    if (c.end >= p){
                        if (!c.count){
                            ++ans1;
                            flag = true;
                        }
                        c.count += 1;
                    }
                }
                else break;
            }
            if (flag) ++ans2;
        }
        cout << ans1 << " " << ans1-ans2 << endl;
    }
    return 0;
}

